<?php

require_once 'Classes/Article.php';

class SearchModel extends PDOModel implements Singleton{
    
     private static $instance;
     
     public function getInstance(){
        if (!isset(self::$instance)) {
            $c = __CLASS__;
            self::$instance = new $c;
        }

        return self::$instance;
     }
     
     public function __clone() {
         throw new Exception("You may not try to clone this object");
     }
 
    public function getArticlesByBarCode($barCode) {
        
        $value = array($barCode);
        $result = $this->PDORequest('SELECT * FROM Articles WHERE BarCode=?', $value);
        
        if($result) {
            $arr[count($result)];
            foreach ($result as $article) {
                array_push($arr, $article);
            }
            return $arr;
        }
        else{
            return array();
        }
    }
	
}

?>